package im.xz.cn.xiacore.menu.mainMenu;

import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;

public class menu_gemini implements Listener {
    @EventHandler
    public void qwq(InventoryClickEvent event) {
        try {
            if (event.getView().getTitle().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "繁星梦服务器菜单") & event.getWhoClicked().hasPermission("xzrui.menu.op")) {
                event.setCancelled(true);
                try {
                    Player player = (Player) event.getWhoClicked();
                    ItemStack item = event.getCurrentItem();
                    if (item.getType().equals(Material.COMMAND_BLOCK)) {
                        event.getWhoClicked().closeInventory();
                        int a = item.getAmount();
                        try {
                            if (a == 1) {
                                try {
                                    if (player.getGameMode().equals(GameMode.CREATIVE)) {
                                        player.performCommand("gms");
                                    }else {
                                        player.performCommand("gmc");
                                    }
                                }catch (NullPointerException ignore) {

                                }
                            }
                        }catch (NullPointerException ignore) {

                        }


                    }
                }catch (NullPointerException ignore) {

                }
            }
        }catch (NullPointerException ignore) {

        }
    }
}
